"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.Club_Freeze_HistoryDao = void 0;
const DbConfig_1 = require("../../src/config/DbConfig");
const DaoBase_1 = require("../../src/engine/dao/DaoBase");
const DateUtil_1 = require("../../src/engine/utils/DateUtil");
const MysqlManager_1 = require("../../src/engine/utils/MysqlManager");
class Club_Freeze_HistoryDao extends DaoBase_1.DaoBase {
    static insert_freeze_history(param) {
        return __awaiter(this, void 0, void 0, function* () {
            let clubid = param["clubid"];
            let freezeid = param["freezeid"];
            let handleid = param["handleid"];
            let freeze_type = param["freeze_type"];
            let time = DateUtil_1.default.formatDateStr(DateUtil_1.default.now());
            let client = yield MysqlManager_1.MysqlManager.instance.getDb(this.DB_NAME);
            let sql = 'INSERT INTO t_club_freeze_history(clubid,freezeid,handleid,freeze_type,time) VALUES(?,?,?,?,?) ;';
            let sqlParams = [clubid, freezeid, handleid, freeze_type, time];
            yield client.queryPromise(sql, sqlParams);
        });
    }
    static get_history(clubid) {
        return __awaiter(this, void 0, void 0, function* () {
            let client = yield MysqlManager_1.MysqlManager.instance.getDb(this.DB_NAME);
            let sql = "select * from v_club_freeze_history where clubid=? order by time desc";
            let sqlParams = [clubid];
            let rows = yield client.queryPromise(sql, sqlParams);
            if (rows && rows.length) {
                return rows;
            }
            return [];
        });
    }
    static clear(delete_time) {
        return __awaiter(this, void 0, void 0, function* () {
            let client = yield MysqlManager_1.MysqlManager.instance.getDb(this.DB_NAME);
            let sql = "delete from t_club_freeze_history where time < ?";
            let sqlParams = [DateUtil_1.default.formatDateStr(delete_time)];
            yield client.queryPromise(sql, sqlParams);
        });
    }
}
exports.Club_Freeze_HistoryDao = Club_Freeze_HistoryDao;
Club_Freeze_HistoryDao.DB_NAME = DbConfig_1.DbConfig.Db_Name.db_admin;
